using Microsoft.EntityFrameworkCore;
using UniversalAdmin.Infrastructure.Data.Contexts;

var builder = WebApplication.CreateBuilder(args);

// 检查连接字符串是否存在，如果不存在则抛出异常或使用默认值
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
if (connectionString == null)
{
    throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
    // 或者使用默认值
    // connectionString = "YourDefaultConnectionString";
}

builder.Services.AddDbContext<ApplicationDbContext>(options 
=> options.UseNpgsql(connectionString));

var app = builder.Build();

app.MapControllers();
app.Run();
